<?php
require('config.php');

        $user_id=$_REQUEST['user_id'];
		$sql="select * from `".$oto."_shops` where `userId`='{$user_id}' and shopFlag='1'";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$shops_info[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($shops_info))
		{
			$data[0]['pan']=-1;
		}
		else
		{
			$data[0]['pan']=1;
			$shopId=$shops_info[0]['shopId'];
			$data[0]['shopName']=$shops_info[0]['shopName'];
			$data[0]['shopSn']=$shops_info[0]['shopSn'];
			$data[0]['img']=$shops_info[0]['shopImg'];
			$time=time();
			$day_sta=strtotime(date('Y-m-d 00:00:00',$time));
			$day_end=strtotime(date('Y-m-d 24:00:00',$time));
			$mod_sta=$time-(3600*24*30);
			$mod_end=$time;
			$data[0]['mod_num']=0;
			$data[0]['mod_money']=0;
			$data[0]['day_num']=0;
			$data[0]['day_money']=0;
			$sql="select * from `".$oto."_orders` where `shopId`='{$shopId}' and paytime>='{$day_sta}' and paytime<'{$day_end}'";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$order_day_info[]=$row;//将取得的所有数据赋值给person_info数组
			}
			$sql="select * from `".$oto."_orders` where `shopId`='{$shopId}' and paytime>='{$mod_sta}' and paytime<'{$mod_end}'";
			$result=$db->query($sql);
			while($row=$result->fetch_assoc()){
				$order_mod_info[]=$row;//将取得的所有数据赋值给person_info数组
			}
			if(isset($order_day_info))
			{
				for($i=0;$i<count($order_day_info);$i++)
				{
					$data[0]['day_money']+=$order_day_info[$i]['needPay'];
				}
				$data[0]['day_num']=count($order_day_info);
			}
			if(isset($order_mod_info))
			{
				for($i=0;$i<count($order_mod_info);$i++)
				{
					$data[0]['mod_money']+=$order_mod_info[$i]['needPay'];
				}
				$data[0]['mod_num']=count($order_mod_info);
			}
		}
		echo json_encode($data);
?>